Date: Wed, 11 Dec 1996 22:34:43 GMT
Server: NCSA/1.5
Content-type: text/html
Last-modified: Thu, 12 Sep 1996 16:47:34 GMT
Content-length: 5771

<HTML>

<HEAD>
<TITLE>CS 302 Section 70 Lecture Notes - Week 1</TITLE>
</HEAD>

<BODY>

<H2><!WA0><!WA0><!WA0><!WA0><!WA0><!WA0><A HREF="http://www.cs.wisc.edu/~tick/cs302.html#text" ><!WA1><!WA1><!WA1><!WA1><!WA1><!WA1><IMG SRC="http://www.cs.wisc.edu/~tick/icons/arrowleft.gif" WIDTH=15 HEIGHT=15></A> Lecture Notes - Week 1</H2>

<HR>

<DL>
   <DT>Topic:
   <DD>Introduction to computers and programming.  How to use Microsoft Windows and Microsoft FORTRAN on the Hewlett-Packard Vectra's

   <DT>Text:
   <DD>Chp. 1.1 - 1.5

   <DT>Notes:
   <DD>

   <HR>

   <CENTER>
   <H3>Introduction to FORTRAN-77</H3>
   </CENTER>

   <H4>Brief History</H4>
   <UL>
      <LI>One of the first high-level programming languages (circa 1957).
      <LI><EM>FOR</EM>ula <EM>TRAN</EM>slator.  Good for engineering and scientific applications.
      <LI>FORTRAN-77 (1977 revision) is the <EM>standard</EM> and most widespread version.  FORTRAN-90 (1990 revision) has additional functionality but is not as widespread.
   </UL>

   <H4>Why learn FORTRAN instead of C++/Pascal/BASIC/...</H4>
   <UL>
      <LI>Easier to write complex formulas and equations.
      <LI>Still widely used in engineering.
      <LI>Lots of existing engineering program libraries are written in FORTRAN.
      <LI>Easy to learn, similar to BASIC.
   </UL>



   <H4>How to use FORTRAN on the PC's</H4>
Click <!WA2><!WA2><!WA2><!WA2><!WA2><!WA2><A HREF="http://www.cs.wisc.edu/~tick/cs302/Short.html"> here </A>

   <H4>Compiling Steps</H4>
   <UL>
     <LI>Source Program (.for) in Fortran sent to compiler
     <LI>Compiler translates Fortran into "machine language with a couple of holes left",spits out .obj file
     <LI>A program may be broken into lots of segments, so there may be other obj's around. At any rate, .objs must be linked together plus some other things needed to "fill in those holes" (don't worry about what the holes are). .obj files all read in, spits out .exe file (runnable machine language).
   </UL>
  
   <H4>Inside the Computer</H4>
   <UL>
       <LI>Input: Keyboard,Mouse
       <LI>Output: Monitor,Printer
       <LI>Inside:
          <UL>
                     <LI>CPU: Central Processing Unit. What does computations.
             <LI>Memory: Where the data is (the program itself and its data)
             <LI>Removable storage. Can take things off disk onto memory or back. Must put things in memory in order to run it.
          </UL>

   </UL>

   <H4>Memory and Binary (to the tune of "Ebony and Ivory"...just kidding)</H4>
   <UL>
       <LI>Each cell of memory (called a bit) either has a charge or has no charge. We call a charge 1 and no charge 0.
<LI>8 bits is one byte (a string of a combo of eight 0's and 1's). Since each bit can be one of 2 things, 2 bits can be one of 4 things (00,01,10,11),3 bits can be one of 8 things (000,001,010,011,100,101,110,111), i.e. 2^n. So a byte lets us store up to 2^8 = 256 different patterns.
<LI>Binary counting:
<UL>
    <LI> Decimal counts 0,1,2,3....9,10,11,....99,100,...999,1000
    <LI> Ones place, tens Place, Hundreds place (i.e. 10^0,10^1,10^2...). This is because each digit can be one of 10 things (just as binary in the example above uses powers of 2).
    <LI> So in binary, we have Ones place, two's place, four's place (i.e. 2^0,2^1,2^2...). Take 1101, for example. In Decimal, 1101 is 1x10^3 + 1x10^2 + 1x10^0. in BINARY, 1101 is 1x2^3 + 1x2^2 + 1x2^0 = 8+4+1 = 13.
</UL>
</UL>
<H4>Machine Language,Assembly,Fortran</H4>
<UL>
<LI>Dark Ages(1960): Since everything stored as 0's and 1's, everything is written that way. For example, 1101 might stand for "add". So 1101 0001 0011 0010 might mean "add whatever's in memory location 0001 to whatever's in 0011 and store the result in memory location 0010" (note the last three sets of digits refer to memory locations). You can't actually add to and from memory locations, so this is not quite a real example, but it gives you an idea of what's going on.
<LI>Machine code is very hard to read. If you saw code like 1101 0001 0011 0010 1010 1111 1110 ... you'd go nuts. Esp. since "add" takes 3 arguments, "move" takes 2 arguments, etc, so hard to tell which sets of numbers stand for commands (like "add") and which stand for memory locations.
<LI>Solution: Assembly language. ADD 0001 0011 0010. Every machine lang. statement corresponds to one assembly statement, and vice versa.
<LI>Problem. Takes a loooong time to write out. You also have to worry about lots of details. Programmers noticed that many times there were sequences of steps that were repeated quite a lot, such as
<BLOCKQUOTE>
LOAD 0001 %r1<p>
LOAD 0011 %r2<p>
ADD %r1 %r2 %r3<p>
STORE %r3 0010<p>
</BLOCKQUOTE>
(Don't worry, you won't have to know this. This is just to show how tedious things were in Assembly Language). This says, take two memory locations and stick their values in registers. A register is a place where you do computations. It's separate from memory (CS354 explains how and why). So in order to compute you have to grab values from memory, stick them on registers, add the two registers into a third register, then store it back into memory somewhere else. WHEW! 
<LI> Instead, it'd be nice to just say SUM = TERM1 + TERM2. This is a Fortran statement which is  translated (compiled) into those assembly instructions you see above. You don't have to worry about where in memory SUM,TERM1,and TERM2 are located...the compiler takes care of that for you. You don't have to worry about registers; again, the compiler does that. So four statements get compacted into one, and you don't even have to deal with binary!
</UL>
</DL>

</BODY>

<HR>

<ADDRESS>
<H5>Copyright &copy 1996 Modified from<!WA3><!WA3><!WA3><!WA3><!WA3><!WA3><A HREF="http://www.cs.wisc.edu/~tick/tick.html">Jeff Lampert</A> (<!WA4><!WA4><!WA4><!WA4><!WA4><!WA4><A HREF="mailto:tick@cs.wisc.edu">tick@cs.wisc.edu</A>).  Last modified September 11, 1996
</ADDRESS>

</HTML>










